<template>
  <div class="item-folder">
    <div v-for="(folder, index) in folders" :key="index" class="item-folder">
      <div class="row">
        <div class="indent" v-for="i in index" :key="i"></div>
        <Label 
          class="folder" 
          :text="folder" 
          :icon="getIcon(index)" 
          :icon-color="getColor(index)"/>
      </div>
    </div>

  </div>
</template>

<script>
import Label from './Label'
export default {
  name: 'ItemFolder',
  components: {
    Label
  },
  props: {
    config: Object
  },
  computed: {
    folders () {
      const folders = this.config.path.split('/')
      folders.push(this.config.name)
      return folders
    }
  },
  methods: {
    getIcon (index) {
      return (index === this.folders.length - 1) ? 'file' : 'folder'
    },
    getColor (index) {
      return (index === this.folders.length - 1) ? '#ee3e3e': '#5a8afb'
    }
  }
}
</script>

<style lang="scss" scoped>
  .item-folder {
    font-size: 14px;
    color: #666;

    .row {
      display: flex;
      .folder {
        flex: 1;
        border-bottom: 1px solid #ddd;
        .li-label__icon {
          font-size: 12px !important;
        }
      }
    }
    .indent {
      width: 20px;
    }
  }
</style>
